package cn.IT.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.IT.dao.IKnowledgeDAO;
import cn.IT.dao.IUserDAO;
import cn.IT.domain.Knowledge;
import cn.IT.domain.Type;
import cn.IT.domain.User;

@Repository
@SuppressWarnings("all")
public class KnowledgeDAO extends BaseDAO<Knowledge> implements IKnowledgeDAO{

	@Override
	public List<Knowledge> getAllKnowledgeBySearchContent(String searchContent) {
		List<Knowledge> list = find("from Knowledge k where k.question like '%"+searchContent+"%'");
		System.out.println(list.size());
		if(!list.isEmpty()){
			return list;
		}
		return null;
	}
	@Override
	public List<Knowledge> getAllKnowledgeByAuthor(User user) {
		List<Knowledge> list = find("from Knowledge k where k.user.userId= '"+user.getUserId()+"'");
		System.out.println(list.size());
		if(!list.isEmpty()){
			return list;
		}
		return null;
	}
	@Override
	public List<Knowledge> getAllKnowledgeByType(Type type) {
		List<Knowledge> list = find("from Knowledge k where k.type.typeName= '"+type.getTypeName()+"'");
		System.out.println(list.size());
		if(!list.isEmpty()){
			return list;
		}
		return null;
	}
	
	
	
}
